Skip to content

Conversation

silvacarloss
Copy link

What this PR does / why we need it:
Manila currently supports only setting a single access rule, making it difficult to have multiple access rules to a shared file system, which is a common scenario in a cloud where we need to have multiple clients being able to mount the shares simultaneously. This PR introduces support for multiple share access rules by accepting a list of IPs/Cephx users instead of a single string.

Which issue this PR fixes(if applicable):
fixes #2725

Special notes for reviewers:

Author of the change stated that they didn't have a CephFS environment, so could not test it with CephFS.
Another pull request was proposed for this issue [1], but due to maintainers not being able to update and rebase the original author's PR, we opened a new PR.
[1] #2727

Release note:

[manila-csi-plugin] Added support for configuring multiple share access rules to a shared filesystem.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 26, 2025
@k8s-ci-robot k8s-ci-robot requested review from Fedosin and tsmetana June 26, 2025 13:15
@k8s-ci-robot
Copy link
Contributor

Welcome @silvacarloss!

It looks like this is your first PR to kubernetes/cloud-provider-openstack 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/cloud-provider-openstack has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 26, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @silvacarloss. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 26, 2025
@kayrus
Copy link
Contributor

kayrus commented Jun 26, 2025

/ok-to-test

I'll make a review a bit later

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 26, 2025
@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from e100d6b to e7984fb Compare July 23, 2025 21:28
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zetaab for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from e7984fb to e1c1dfc Compare July 24, 2025 12:23
@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from e1c1dfc to a4a50ea Compare August 4, 2025 17:03
Copy link
Contributor

@gouthampacha gouthampacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @silvacarloss

Thanks for updating this change. Please see comments inline

@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from a4a50ea to 978dd3d Compare August 14, 2025 13:50
Copy link

linux-foundation-easycla bot commented Aug 14, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: moonek / name: Mason Choi (bf72548)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 14, 2025
@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from cc098b5 to 7e80d0a Compare August 18, 2025 15:27
@silvacarloss
Copy link
Author

/retest

@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from 7e80d0a to bcfd545 Compare August 20, 2025 18:20
Copy link
Contributor

@gouthampacha gouthampacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, a comment inline regarding backwards compatibility; I think you've demonstrated that it works well with NFS, and it'd be nice to test with CephFS as well to be sure. Thanks @silvacarloss

Copy link
Contributor

@mandre mandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need to polish the options for cleanliness and more importantly to avoid breaking backward compatibility. I'm also surprised that it's working at all since we seems to be using a deprecated API call to list accesses which is supposed to return 404.

@@ -46,7 +46,7 @@ type ShareAdapter interface {
// GetOrGrantAccess first tries to retrieve an access right for args.Share.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the godoc as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -131,6 +119,7 @@ func (ns *nodeServer) buildVolumeContext(ctx context.Context, volID volumeID, sh
// Build volume context for fwd plugin

sa := getShareAdapter(ns.d.shareProto)
accessRight = getAccessRightBasedOnShareAdapter(sa, accessRights, shareOpts.ShareAccessIDs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not using the returned value, perhaps replace the variable with _ ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question... accessRight was defined in the function signature, so it's empty. When we get to this getAccessRightBasedOnShareAdapter function, it might (or might not) return an access right, which should populate the accessRight value that will be returned, so it's part of assigning a value so it will work with the naked return behavior. I'm kinda new to go and not sure if the naked return is a good practice, so please let me know if this is okay :)

})
// Search again because access rights have changed
if created {
rights, err = args.ManilaClient.GetAccessRights(ctx, args.Share.ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can save the extra API call if we append the returned accesses from the calls args.ManilaClient.GrantAccess() to rights.

Also, as a side note, it looks like args.ManilaClient.GetAccessRights() is using gophercloud's shares.ListAccessRights() function, which in turns make a call to a deprecated API. The doc says that it will return 404 starting from microversion 2.45, which is OpenStack Rocky. I suspect we're always getting a 404 error for all calls to args.ManilaClient.GetAccessRights(). This would be problematic on line 39.

It should be using shareaccessrules.List() instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this deprecated API call is actually tracked in #2277.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we're setting the client micro-version to 2.37, which explains why it's working.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, this call has to change indeed. Can we make this a part of a follow-up change though? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on bumping the microversion with a different change; it's desirable to not depend on an old API version - it'll certainly simplify things, and we'll get to use newer features including the ability to paginate and such.

klog.V(4).Infof("cephx access right for share %s already exists", args.Share.Name)
accessToList := []string{args.Share.Name}
if args.Options.CephfsClientID != "" {
accessToList = strings.Split(args.Options.CephfsClientID, ",")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for NFS, we should document that cephfs-clientID takes a list of comma-separated IDs.

That being said, we probably need a new option in plural form, deprecating cephfs-clientID. Same goes for nfs-shareClient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the doc. Can we keep the current options for now and follow-up on this later? We should also introduce one of the things I mentioned in the todos: get the node's context and simplify the nodeserver code by only looking up for the access rule that will be used for that given node.

@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from bcfd545 to d308dc2 Compare August 21, 2025 17:52
Copy link
Author

@silvacarloss silvacarloss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the feedback. Please take a look at the changes and replies inline :)

@@ -131,6 +119,7 @@ func (ns *nodeServer) buildVolumeContext(ctx context.Context, volID volumeID, sh
// Build volume context for fwd plugin

sa := getShareAdapter(ns.d.shareProto)
accessRight = getAccessRightBasedOnShareAdapter(sa, accessRights, shareOpts.ShareAccessIDs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question... accessRight was defined in the function signature, so it's empty. When we get to this getAccessRightBasedOnShareAdapter function, it might (or might not) return an access right, which should populate the accessRight value that will be returned, so it's part of assigning a value so it will work with the naked return behavior. I'm kinda new to go and not sure if the naked return is a good practice, so please let me know if this is okay :)

klog.V(4).Infof("cephx access right for share %s already exists", args.Share.Name)
accessToList := []string{args.Share.Name}
if args.Options.CephfsClientID != "" {
accessToList = strings.Split(args.Options.CephfsClientID, ",")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the doc. Can we keep the current options for now and follow-up on this later? We should also introduce one of the things I mentioned in the todos: get the node's context and simplify the nodeserver code by only looking up for the access rule that will be used for that given node.

@@ -46,7 +46,7 @@ type ShareAdapter interface {
// GetOrGrantAccess first tries to retrieve an access right for args.Share.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

})
// Search again because access rights have changed
if created {
rights, err = args.ManilaClient.GetAccessRights(ctx, args.Share.ID)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, this call has to change indeed. Can we make this a part of a follow-up change though? :)

Copy link
Contributor

@gouthampacha gouthampacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @silvacarloss ; this looks good to me hoping CI passes.

@@ -43,10 +43,11 @@ type SecretArgs struct {
}

type ShareAdapter interface {
// GetOrGrantAccess first tries to retrieve an access right for args.Share.
// An access right is created for the share in case it doesn't exist yet.
// GetOrGrantAccess first tries to retrieve the list of access rights for args.Share.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is now GetOrGrantAccesses.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, fixed it now :)

Signed-off-by: moonek <[email protected]>
Signed-off-by: Carlos da Silva <[email protected]>
@silvacarloss silvacarloss force-pushed the support-multiple-share-rules-manila-csi branch from d308dc2 to bf72548 Compare August 21, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[manila-csi-plugin] support muilple share rules
6 participants